package com.itmk.home;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/studentHome.do")
public class StudentHomeServlet extends HttpServlet {
     private static final String PREX = "WEB-INF/jsp/student";
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String method = req.getParameter("method");
        if(method.equals("selectCourse")){
            selectCourse(req, resp);
        }else if(method.equals("myCourse")){
            myCourse(req, resp);
        }else if(method.equals("lookPoint")){
            lookPoint(req, resp);
        }
    }

    private void lookPoint(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
         req.getRequestDispatcher(PREX+"/look_point.jsp").forward(req,resp);
    }

    private void myCourse(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.getRequestDispatcher(PREX+"/my_course.jsp").forward(req,resp);
    }

    private void selectCourse(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.getRequestDispatcher(PREX+"/select_course.jsp").forward(req,resp);
    }
}
